package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.AnesthesiaMethod;
import com.ruoyi.manage.service.IAnesthesiaMethodService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 麻醉方式Controller
 * 
 * @author liuyangyang
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/manage/anesthesiamethod")
public class AnesthesiaMethodController extends BaseController
{
    @Autowired
    private IAnesthesiaMethodService anesthesiaMethodService;

    /**
     * 查询麻醉方式列表
     */
    @PreAuthorize("@ss.hasPermi('manage:anesthesiamethod:list')")
    @GetMapping("/list")
    public TableDataInfo list(AnesthesiaMethod anesthesiaMethod)
    {
        startPage();
        List<AnesthesiaMethod> list = anesthesiaMethodService.selectAnesthesiaMethodList(anesthesiaMethod);
        return getDataTable(list);
    }

    /**
     * 导出麻醉方式列表
     */
    @PreAuthorize("@ss.hasPermi('manage:anesthesiamethod:export')")
    @Log(title = "麻醉方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnesthesiaMethod anesthesiaMethod)
    {
        List<AnesthesiaMethod> list = anesthesiaMethodService.selectAnesthesiaMethodList(anesthesiaMethod);
        ExcelUtil<AnesthesiaMethod> util = new ExcelUtil<AnesthesiaMethod>(AnesthesiaMethod.class);
        util.exportExcel(response, list, "麻醉方式数据");
    }

    /**
     * 获取麻醉方式详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:anesthesiamethod:query')")
    @GetMapping(value = "/{anesthesiaMethodId}")
    public AjaxResult getInfo(@PathVariable("anesthesiaMethodId") Long anesthesiaMethodId)
    {
        return success(anesthesiaMethodService.selectAnesthesiaMethodByAnesthesiaMethodId(anesthesiaMethodId));
    }

    /**
     * 新增麻醉方式
     */
    @PreAuthorize("@ss.hasPermi('manage:anesthesiamethod:add')")
    @Log(title = "麻醉方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnesthesiaMethod anesthesiaMethod)
    {
        return toAjax(anesthesiaMethodService.insertAnesthesiaMethod(anesthesiaMethod));
    }

    /**
     * 修改麻醉方式
     */
    @PreAuthorize("@ss.hasPermi('manage:anesthesiamethod:edit')")
    @Log(title = "麻醉方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnesthesiaMethod anesthesiaMethod)
    {
        return toAjax(anesthesiaMethodService.updateAnesthesiaMethod(anesthesiaMethod));
    }

    /**
     * 删除麻醉方式
     */
    @PreAuthorize("@ss.hasPermi('manage:anesthesiamethod:remove')")
    @Log(title = "麻醉方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{anesthesiaMethodIds}")
    public AjaxResult remove(@PathVariable Long[] anesthesiaMethodIds)
    {
        return toAjax(anesthesiaMethodService.deleteAnesthesiaMethodByAnesthesiaMethodIds(anesthesiaMethodIds));
    }
}
